<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@ include file="/WEB-INF/views/shared/taglib.jsp"%>
<%
	request.setAttribute("title", "商品详情");
%>
<%@ include file="/WEB-INF/views/shared/master/weContentHeader.jsp"%>

<style type="text/css">
	.weui-tabbar__item{
		font-size:0.5rem;
		height:2.5rem;
		padding:0;
		line-height:0.8rem;
		-webkit-tap-highlight-color: rgba(180,180,180,0.15);
	}
	
	.weui-tabbar{
		position:fixed !important;
	}
	.goodBox{
		width:100%;
	}
	.icon{
		width:1.0rem;
		margin-top:0.3rem;
	}
	.icon_name{
		color:grey;
	}
	.good_picture{
		width:100%;
		height:16.5rem;
	}
	
	.buy{
		line-height:2.5rem;
		font-size:0.8rem;
		color:#ffffff;
	}
	.good_description{
		width:95%;
		margin:0 auto;
	}
	.good_name{
		overflow: hidden;
		text-overflow: ellipsis;
		display:-webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}
	
	.weui-media-box_appmsg .weui-media-box__hd{
		width:2.5rem;
		height:2.5rem;
		line-height:2.5rem;
		border：1px solid #d9d9d9;
	}
	.weui-media-box{
		padding:0.8rem;
	}
	.weui-media-box__title{
		font-size:0.75rem;
	}
	
	
</style>
<%@ include file="/WEB-INF/views/shared/master/weTitle.jsp"%>
	 <input type="hidden" id="fromWhere" value="${fromWhere}"/>
	 <input type="hidden" id="id" value="${goodsService.id}" data-type="goodType"/>
	
	<div class="goodBox">
		 <img class="good_picture" src="<c:url value='/images/we/ser/test.jpg'/>" />
		 <div class="good_description">
			 <p class="good_name">${goodsService.serviceGoodsName}</p>
			 <div class="money">
				<span style="color:red;font-size:1.2rem;">${goodsService.goodsMaketPrice}</span>
				<span style="color:red;font-size:0.7rem;">
					<t:provider packageName="ser" enumClassName="GoodsCurrencyState" value="${goodsService.goodsMaketCurrency}"/>
				</span>
			 </div>
			 <div> 
			 	<span style="color:grey;text-decoration:line-through;font-size:0.7rem;">
			 		原价：${goodsService.goodsOriginalPrice}
			 		<t:provider packageName="ser" enumClassName="GoodsCurrencyState" value="${goodsService.goodsOriginalCurrency}"/>
			 	</span>
			 	<span style="color:grey;font-size:0.7rem;padding-left:2.0rem;">库存${goodsService.serviceGoodsNum}件</span>
			 	<span style="color:grey;font-size:0.7rem;padding-left:4rem;">${goodsService.goodStore.storeAddress}</span>
			 </div>
		 </div>
	</div>
	
	<div style="width:100%;height:0.5rem;background-color:#ededed;margin-top:0.5rem;"></div>
	<div class="goodStore">
		<div class="weui-panel weui-panel_access">
		  <div class="weui-panel__bd">
		    <a href="#" class="weui-media-box weui-media-box_appmsg">
		      <div class="weui-media-box__hd">
		        <img class="weui-media-box__thumb" style="width:2.5rem;height:2.5rem;" src="<c:url value='/images/we/ser/storePicture.jpg' />">
		      </div>
		      <div class="weui-media-box__bd">
		        <p class="weui-media-box__title">${goodsService.goodStore.storeName}</p>
		      </div>
		    </a>
		  </div>
		 </div>
	</div>	
	<div style="width:100%;height:2.5rem;"></div>
	 
	 <div class="weui-tabbar">
	    <a href="#" class="weui-tabbar__item" style="flex-grow:1;">
	      	<img class="icon" src="<c:url value='/images/we/ser/store.png'/>" />
	      	<div class="icon_name">店铺</div>
	    </a>
	    <a href="javascript:void(0);" class="weui-tabbar__item" style="flex-grow:1;" id="collect">
	      	<img class="icon" id="collectpicture" src="<c:url value='/images/we/informationDetails/star1.png'/>" />
	   		<div>收藏</div>
	    </a>
	  	<a href="#" class="weui-tabbar__item" style="flex-grow:2;background-color:#e50012;">
	     	<p class="buy">立即购买<p>
	    </a>
	  </div>

<%@ include file="/WEB-INF/views/shared/scripts/jquery.jsp"%>
<%@ include file="/WEB-INF/views/shared/scripts/jqweui.jsp"%>

<script type="text/javascript">
	function goback(){
		var fromWhere = $("#fromWhere").val();
		if(fromWhere=="service"){
			window.location.href=$.getVirtualPath()+"/wechat/ser/serIndex/service";
		}else if(fromWhere=="collectIndex"){
			window.location.href=$.getVirtualPath()+"/wechat/cust/colAndFoot/collectIndex";
		}
	}
	
	$(function(){
		
		/* 全局变量id和类型 */
		var $input = $("#id");
		var type = $input.data("type");
		var thingId = $input.val();
		
		/*在足迹表中插入一条数据 */
		var action = $.getVirtualPath()+"/wechat/allFootprint/addFootprint?type="+type+"&thingId="+thingId;
		$.getTextPost(action);
		
		/*根据初始状态展示收藏状态	*/
		var state;

		var url = $.getVirtualPath()+"/wechat/allCollect/isCollect?type="+type+"&thingId="+thingId;
		var result = $.getTextPost(url);
		if(result=="true"){
			$("#collectpicture").attr("src","<c:url value='/images/we/informationDetails/star2.png'/>"); 
			state = 0;
		}else{
			$("#collectpicture").attr("src","<c:url value='/images/we/informationDetails/star1.png'/>");
			state = 1;
		}
		
		//收藏
		$("#collect").on("click",function () {
			if(state==0){
				//取消收藏
				var url = $.getVirtualPath()+"/wechat/allCollect/delete?type="+type+"&thingId="+thingId;
				var result = $.getTextPost(url);
				if(result="true"){
					state = 1;
					$("#collectpicture").attr("src","<c:url value='/images/we/informationDetails/star1.png'/>");
				}else{
					$.toast("取消失败");
					state = 0;
				}
				
			}else if (state==1) {			
				//添加收藏
				var url = $.getVirtualPath()+"/wechat/allCollect/addCollect?type="+type+"&thingId="+thingId;
				var result = $.getTextPost(url);
				if(result="true"){
					state=0;
					$("#collectpicture").attr("src","<c:url value='/images/we/informationDetails/star2.png'/>");
				}else{
					$.toast("收藏失败");
				}
			}
			
		});
		
	});		

</script>

<%@ include file="/WEB-INF/views/shared/master/weContentFooter.jsp"%>
